#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using Cysharp.Threading.Tasks;
using Neatly.Module;

namespace Neatly.Load.Manager
{
    public class AtlasLoadManager : Singleton<AtlasLoadManager>
    {
        private LoadModule m_LoadModule;

        public void Init(LoadModule loadModule)
        {
            m_LoadModule = loadModule;
        }

        //加载图集padding信息
        public async UniTask<AtlasConfig> LoadAtlasConfig()
        {
            if (NeatlyConfig.AssetBundleEnable)
            {
                var loader = await m_LoadModule.LoadAssetBundleDirect(NeatlyConfig.PATH_BUNDLE_ATLAS_CONFIG);
                var atlasConfig = loader.LoadAsset<AtlasConfig>(NeatlyConfig.NAME_ATLAS_CONFIG);
                loader.Unload(false);
                return atlasConfig;
            }
            var (_, result) = await m_LoadModule.LoadAssetFile<AtlasConfig>(NeatlyConfig.PATH_FILE_ATLAS_CONFIG);
            return result;
        }
    }
}